const app =getApp();
import ChatSession from '../entity/ChatSession.js'
export default{
  /**
   * 从全局变量中获取指定OpenId的用户信息
   * @param {用户id}} openId 
   */
  getUserInfoWithOpenId(openId){
       var contactList =app.globalData.contactList;
       return contactList.find((item)=>item.id==openId)
  },
  /**
   * 创建一个会话item
   * @param {*} userInfo 
   * @param {*} msg 
   */
  createChatSession(userInfo,msg){
    return new ChatSession(userInfo,msg);
  },

  createNewSessionItem(fromUser,msg){
    return {"messageCount":0,"id":fromUser.id,"userName":fromUser.userName,"profileUrl":fromUser.profileUrl,"lastMessage":msg}
  },

}